/**
 *
 *  @author ala
 *  @date 2024-09-23 10:16
 */
package tools

import (
	"LeetCode/study_go/dto"
	_ "container/heap"
)

type PriorityQueue []*dto.Student

func (pq *PriorityQueue) Len() int {
	return len(*pq)
}
func (pq *PriorityQueue) Less(i, j int) bool {
	_pq := *pq
	return _pq[i].Age < _pq[j].Age
}
func (pq *PriorityQueue) Swap(i, j int) {
	_pq := *pq
	_pq[i], _pq[j] = _pq[j], _pq[i]
}
func (pq *PriorityQueue) Push(x interface{}) {
	*pq = append(*pq, x.(*dto.Student))
}
func (pq *PriorityQueue) Pop() interface{} {
	_pq := *pq
	l := len(_pq) - 1
	last := _pq[l]
	*pq = _pq[0 : l-1]
	_pq[l-1] = nil
	return last
}
